package com.flyan.game.motafx.core.enums;

import javafx.geometry.Point2D;

/**
 * 方向
 *
 * @author flyan
 * @version 1.0
 * @email flyan_by_chenu@sina.com
 * @since 2025/1/31
 */
public enum DirEnum {

    UP(new Point2D(0, -1)),
    DOWN(new Point2D(0, 1)),
    LEFT(new Point2D(-1, 0)),
    RIGHT(new Point2D(1, 0));

    /**
     * 方向向量
     */
    private final Point2D vector;

    DirEnum(Point2D vector) {
        this.vector = vector;
    }

    public Point2D getVector() {
        return vector;
    }

    public DirEnum reverse() {
        switch (this) {
            case UP -> {
                return DOWN;
            }
            case DOWN -> {
                return UP;
            }
            case LEFT -> {
                return RIGHT;
            }
            case RIGHT -> {
                return LEFT;
            }
            default -> {
                throw new AssertionError("dead code.");
            }
        }
    }

}
